package org.halk.redis.lock;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;

import java.util.Map;

/**
 * @Author halk
 * @Description 测试自定义注解
 * @Date 2021/12/24 10:28
 **/
@SpringBootApplication
/**
 * springBoot不需要此注解，会根据AopAutoConfiguration类自动判断，如果 classpath 下有 spring-aop 的 jar
 * 和有 EnableAspectJAutoProxy 类等，它就会自动开启 spring-aop，也可以通过配置文件、配置类控制
 *
 * 非springboot项目则需要此竹节
 */
//@EnableAspectJAutoProxy
public class RedisLockDemoApplication {

    public static void main(String[] args) {

//        ConfigurableApplicationContext run1 = SpringApplication.run(RedisLockDemoApplication.class, args);
//        ConfigurableEnvironment environment1 = run1.getEnvironment();

        SpringApplication application = new SpringApplication(RedisLockDemoApplication.class);
        /*
         * Banner.Mode.OFF:关闭;
         * Banner.Mode.CONSOLE:控制台输出，默认方式;
         * Banner.Mode.LOG:日志输出方式;
         */
        application.run(args);

        //多种启动方式
        SpringApplicationBuilder springApplicationBuilder = new SpringApplicationBuilder(RedisLockDemoApplication.class);
        ConfigurableApplicationContext run = springApplicationBuilder.run(args);

        //获取环境信息
        ConfigurableEnvironment environment = run.getEnvironment();

        Map<String, Object> systemEnvironment = environment.getSystemEnvironment();
        systemEnvironment.forEach((k, v) -> System.out.println(k + ":\t" + v));

        System.out.println("----------------------");

        environment.getSystemProperties().forEach((k, v) -> System.out.println(k + ":\t" + v));
//        new SpringApplicationBuilder(RedisLockDemoApplication.class)
//                .run(args);

    }

}
